package com.translate.web.api;

import javax.servlet.MultipartConfigElement;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.unit.DataSize;

import com.common.util.CopyEntity;


@SpringBootApplication(scanBasePackages = { "com.translate.web", "com.email", "com.common.conf" })
@Configuration
@MapperScan({ "com.translate.web.dao.**", "com.translate.web.api.mapper.**" })
public class TranslateWebApplication {

	public static void main(String[] args) {

		CopyEntity.closeOut();

		SpringApplication.run(TranslateWebApplication.class, args);
	}

	/**
	 * 文件上传配置
	 * @return
	 */
	@Bean
	public MultipartConfigElement multipartConfigElement() {
		MultipartConfigFactory factory = new MultipartConfigFactory();
		// 单个数据大小
		factory.setMaxFileSize(DataSize.ofMegabytes(100)); // KB,MB
		/// 总上传数据大小
		factory.setMaxRequestSize(DataSize.ofMegabytes(1000));
		return factory.createMultipartConfig();
	}

}
